﻿package Classes.Enemies.Emplacements
{
	import flash.display.*;
	import flash.geom.*;
	import flash.media.*;
	
	import Classes.Weapons.*;
	import Classes.Elements.*;
	import Classes.Weapons.Bullets.*;	
	import Classes.Enemies.*;
	import Classes.Utils.*;
	import Classes.Sounds.GameSound;
	
	public class Cannon extends Emplacement{
		
		public function Cannon(){			
			pointable = true;
			aFirePoints = [[0,0]];
			omega = 10;			
			life = 80;
			hp = 80;
			execution = 30;
			weaponType = WeaponType.PhotonBullet;
			score = UnitType.Cannon.score;
		}
		override public function fire():void{			
			if((inc + 3) % weaponType.interval == 0){
				this.gotoAndPlay("fire");
				pointable = false;
			}
			if(inc % weaponType.interval == 0){				
				//GameSound.PhotonBulletShoot.play();
				for(var i=0;i<5;i++){
					var pb:PhotonBullet = new PhotonBullet();
					var gpos:Array = getGolbalFirePoints();
					pb.aTargets = this.aTargets;
					pb.angle = -this.rotation + (30 - i*15);
					pb.sender = this;
					pb.x = gpos[0][0];
					pb.y = gpos[0][1];
					bulletLayer.addChild(pb);				
					pointable = true;
				}
			}			
		}
		override protected function move():void{
			inc++;
			super.move();
			if(pointable)
				Moving.pointTo(this,aTargets[0],omega);
			if(fireable)
				fire();;
		}
	}
}